package requests

import (
	"github.com/flaravel/quanlaolao/app/models/cps"
	"github.com/thedevsaddam/govalidator"
)

func ValidateCpsForm(data cps.Cps) map[string][]string {

	rules := govalidator.MapData{
		"title" : []string{"required","max_cn:30"},
		"channel_id" : []string{"required"},
	}

	messages := govalidator.MapData{
		"title": []string{
			"required:标题为必填项",
			"max_cn:标题长度需小于 30",
		},
		"channel_id": []string{
			"required:渠道必填项",
		},
	}
	opts := govalidator.Options{
		Data:          &data,
		Rules:         rules,
		TagIdentifier: "valid", // 模型中的 Struct 标签标识符
		Messages:      messages,
	}
	return govalidator.New(opts).ValidateStruct()
}
